<script setup lang="ts">
const { login } = useLogin()
const toast = useToast()
const route = useRoute()
const directus = useDirectus()

try {
  await directus.refresh()
  login.value.isLoggedIn = true
  await navigateTo(route.query.redirect as string)
}
catch (error) {
  toast.add({
    title: 'SSO Login Error',
    description: directusErrorMessage(error),
    color: 'red',
  })
  await navigateTo('/login')
}
</script>
